<?php

class AstorController extends Controller
{
	public $pageKeyword;
	public $pageDescription;
	public function actions()
	{

	}
	public function actionTommorow()
	{
		$this->render('tommorow');
	}
	public function actionDays()
	{

	}
	public function actionWeek()
	{
	}
	public function actionMonth()
	{

	}
	public function actionBirthdetail()
	{
		if(isset($_GET["i"]))
		{
			$param = (int)$_GET["i"];
			$cache_key = md5("AstorInfoContents_".$param);
			$infos = Yii::app()->cache->get($cache_key);
			if($infos===false)
			{
				$infos = AstorInfo::model()->findByPK($param);
				Yii::app()->cache->set($cache_key, $infos ,18000);
			}
			if(!empty($infos))
			{
				$this->pageTitle = $infos->info_month.'月'.$infos->info_day.'日出生的人，配什么星座好|'.$infos->info_month.'月'.$infos->info_day.'日出生的人,性格'.$infos->info_intro.'|为什么你伤不起';
			}

			$this->render("birthdetail",array("infos"=>$infos));
		}
	}
	public function actionInfos()
	{
		$astor_arr = Yii::app()->params["astors"];
		$new_arr = array();
		$astor_content = "暂无此星座的详细信息";
		if(isset($_GET["p"]))
		{
			$param = $_GET["p"];
			foreach($astor_arr as $key=>$value)
			{
				$styles = ($key===$param)?"seled":"";
				$new_arr[$key] = array($value[0],$value[1],$styles);
			}
			if(in_array($param,array_keys($astor_arr)))
			{
				$astor_content = $new_arr[$param][1];
				$this->pageTitle = $new_arr[$param][0].'座人生日密码_性格分析_一切尽在游离氧吧_www_oliyo_com';
			}
			$cache_key = md5("AstorInfoLists_".$param);
			$AstorList = Yii::app()->cache->get($cache_key);
			if ( $AstorList===false ) {
				$AstorInfoId = AstorMaster::model()->findByAttributes(array("astor_mark"=>$param));
				$AstorList = AstorInfo::model()->findAllByAttributes(array("astor_id"=>$AstorInfoId->astor_id));
				Yii::app()->cache->set($cache_key, $AstorList ,7200);
			}
		}

		$this->render("infos",array("astors"=>$new_arr,"astor_content"=>$astor_content,"astor_list"=>$AstorList));
	}
	public function actionInprotypes()
	{
		if(isset($_GET["p"]) && isset($_GET["i"]))
		{
			$param = $_GET["p"];
			$infoId = (int)$_GET["i"];
			$cache_key = md5("AstorInfoProtypes_".$param."inid_".$infoId);
			$Infos = Yii::app()->cache->get($cache_key);

			if($Infos===false)
			{
				$Infos = AstorProtype::model()->findByPk($infoId);
				Yii::app()->cache->set($cache_key, $Infos ,18000);
			}
			$this->pageTitle = $Infos->p_key.'_性格分析_一切尽在游离氧吧_www_oliyo_com';

		}
		$this->render("protypes",array("infos"=>$Infos));
	}
	public function actionIndex()
	{
		$value = Yii::app()->cache->get("IndexAstorContent");
		if ( $value===false ) {
			$sql = " SELECT * FROM web_astor_master ";
			$value = Yii::app()->db->createCommand($sql)->queryAll();
			Yii::app()->cache->set("IndexAstorContent", $value ,30);
		}
		$rnd_color = array("#6600CC",'#009933','#336633','#333300');
		$this->render('index',array('cacheTest'=>$value,'rnd_color'=>$rnd_color));
	}
	public function formatOut($outString)
	{
		$t="";
		$tmp = array();
		$tmp_t = "";
		if($outString!="")
		{
			$outString = str_replace("　","<br/>",$outString);
			if(stripos($outString,"<br/>")>0){
				$temp = explode("<br/>",$outString);

				 
				foreach($temp as $t)
				{
					$tmp_t = "";
					$tmp_t = "<p class=\"fmatout\">".$t."</p>";
					if($tmp_t!="<p class=\"fmatout\"></p>")
					{
						$tmp[] = $tmp_t;
					}

				}
				return trim(str_replace("<p class=\"fmatout\"></p>","",implode("",$tmp)));
			}else{return $outString;}
		}
	}

	// -----------------------------------------------------------
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
	// return the filter configuration for this controller, e.g.:
	return array(
	'inlineFilterName',
	array(
	'class'=>'path.to.FilterClass',
	'propertyName'=>'propertyValue',
	),
	);
	}

	public function actions()
	{
	// return external action classes, e.g.:
	return array(
	'action1'=>'path.to.ActionClass',
	'action2'=>array(
	'class'=>'path.to.AnotherActionClass',
	'propertyName'=>'propertyValue',
	),
	);
	}
	*/
}